package com.mjlf.robot;

import java.awt.event.*;

import javax.swing.JFrame;  
  
  
/** 
 *  
 */  
  
/** 
 * @author Administrator 
 * 
 */  
//窗体类   
public class MyFrame extends JFrame {  
  
    /** 
     * @param args 
     */  
    char charA;  
    public MyFrame(){  
        this.setSize(500,100);  
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        this.setTitle("my jframe");  
        this.setVisible(true);  
        this.addKeyListener(new MyKeyListener());  
        this.addMouseListener(new MyMouseListener());
        this.addMouseMotionListener(new AAA());

    }  
      
      
      
    public static void main(String[] args) {  
        // TODO Auto-generated method stub   
        new MyFrame();  
    }  
  
}  
//监听键盘类   
class MyKeyListener extends KeyAdapter{
    @Override
    public void keyPressed(KeyEvent e){  
        char charA=e.getKeyChar();  
        System.out.println("你按了《"+charA+"》键");  
    }  
}

class MyMouseListener extends MouseAdapter {
    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getClickCount() == 1) {
            System.out.println("点击一下");
        } else if (e.getClickCount() == 2) {
            System.out.println("点击两下");
        } else if (e.getClickCount() == 3) {
            System.out.println("点击三下");
        }
        System.out.println(e.getXOnScreen());
    }

    @Override
    public void mousePressed(MouseEvent e) {
        super.mousePressed(e);
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        super.mouseReleased(e);
    }
}

class AAA implements MouseMotionListener{

    @Override
    public void mouseDragged(MouseEvent e) {
        System.out.println(e.getX());
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        System.out.println("eeee");
        System.out.println(e.getX());
    }
}